package cn.wolfcode.crm.domain;

import com.alibaba.fastjson.JSON;
import lombok.Getter;
import lombok.Setter;

import java.util.Date;
import java.util.HashMap;
import java.util.Map;

@Getter
@Setter
public class Customer {
    private Long id;

    private String name;

    private Integer age;

    private Integer gender;

    private String tel;

    private String qq;

    private SystemDictionaryItem job;

    private SystemDictionaryItem source;

    private Employee seller;

    private Employee inputUser;

    private Date inputTime;

    private Integer status;

    private Date positiveTime;

    public static final int GENDER_FEMALE   = 0; // 女
    public static final int GENDER_MALE     = 1; // 男

    public static final int STATUS_POTENTIAL = 0;  // 潜在
    public static final int STATUS_FORMAL    = 1;  // 正式
    public static final int STATUS_POOL      = 2;  // 资源池
    public static final int STATUS_FAILURE   = 3;  // 失败
    public static final int STATUS_LOST      = 4;  // 流失

    public String getGenderName(){
        if (this.gender == null){
            return "未知";
        }else if(this.gender == GENDER_FEMALE){
            return "女";
        }else {
            return "男";
        }
    }
    public String getStatusName(){
        if (this.status == STATUS_POTENTIAL){
            return "潜在";
        }else if(this.status == STATUS_FORMAL){
            return "正式";
        }else if(this.status == STATUS_POOL){
            return "资源池";
        }else if(this.status == STATUS_FAILURE){
            return "失败";
        }else if(this.status == STATUS_LOST){
            return "流失";
        } else {
            return "未知";
        }
    }


    public String getJsonData(){
        Map<String,Object> data = new HashMap<>();
        data.put("id",this.getId());
        data.put("name",this.getName());
        data.put("age",this.getAge());
        data.put("genderName",this.getGenderName());
        data.put("gender",this.getGender());
        data.put("tel",this.getTel());
        data.put("qq",this.getQq());
        data.put("job",this.getJob());
        data.put("source",this.getSource());
        data.put("seller",this.getSeller());
        data.put("sellerName",this.getSeller().getName());
        data.put("sellerId",this.getSeller().getId());
        data.put("inputUser",this.getInputUser());
        data.put("inputTime",this.getInputTime());
        data.put("status",this.getStatus());
        data.put("positiveTime",this.getPositiveTime());
        return JSON.toJSONString(data);
    }
}